package com.lxw.study.creational.simplefactory;


public class ComputerFactory {
    public static Computer makeComputer(String name){
        Computer computer = null;
        if ("小米".equals(name)) {
            computer = new Computer4Mi();
        }
        if ("Mac".equals(name)) {
            computer = new Computer4Mac();
        }
        return computer;

    }
    public static Computer makeComputer(Class c){
        try {
            Computer computer = (Computer) c.newInstance();
            return computer;
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
